home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 March / Macworld CD-ROM (March 1995).cdr / Updaters / AppMaker 1.5.2->1.5.4 / Libraries / THINK / AMClassLibC / CAMTable.cp < prev    next >
Encoding:
Text File  |  1991-11-24  |  2.8 KB  |  98 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CAMTable.c
  3.         
  4.     
  5.     Like the Table class that it overrides, except that font, size and
  6.     style can be set at creation time.
  7.  
  8.     SUPERCLASS = CTable
  9.     
  10.     Copyright © 1991 Bowers Development Corporation. All rights reserved.
  11.  
  12.  ******************************************************************************/
  13.  
  14. #include "CAMTable.h"
  15. #include <TBUtilities.h>
  16.  
  17. /******************************************************************************
  18.  IViewTemp
  19.  
  20.      Initialize an AM Table using a template
  21.  
  22. ******************************************************************************/
  23. void CAMTable::IViewTemp        (CView            *anEnclosure,
  24.                                   CBureaucrat    *aSupervisor,
  25.                                  Ptr            viewData)
  26. {
  27.     register        AMTableTempP        p;
  28.  
  29.     p = (AMTableTempP) viewData;
  30.     theTypeStyleP = &p->typeStyle;
  31.     inherited::IViewTemp (anEnclosure, aSupervisor, (Ptr)&p->sTableTemp);
  32.     theTypeStyleP = nil;
  33.  
  34. } /* IViewTemp */
  35.  
  36. /******************************************************************************
  37.  CreateTextEnvironment {OVERRIDE}
  38.  
  39.     Create and initialize the text environment used for drawing text.
  40.     Read the info from the saved style ptr.
  41. ******************************************************************************/
  42.  
  43. void CAMTable::CreateTextEnvironment (void)
  44. {
  45.     AMSetupTextEnvirons (this, &theTypeStyleP->editStyles);
  46.  
  47. } /* CreateTextEnvironment */
  48.  
  49. /******************************************************************************
  50.  HasSelection
  51.  
  52.     Returns a boolean to indicate whether anything is selected.
  53. ******************************************************************************/
  54. Boolean CAMTable::HasSelection    (void)
  55. {
  56.     return (!EmptyRgn (GetSelection ()));
  57.  
  58. } /* HasSelection */
  59.  
  60. /******************************************************************************
  61.  GetChoice
  62.  
  63.     This is a wrapper routine for the very common kind of list which
  64.     has a single column and allows only one item to be selected.
  65.     Returns in its parameter the row (0..N) of the selected item.
  66.     Returns as function result whether anything is selected.
  67. ******************************************************************************/
  68. Boolean    CAMTable::GetChoice        (short            *choice)
  69. {
  70.     Cell            aCell;
  71.  
  72.     SetPt (&aCell, 0, 0);
  73.     if (GetSelect (TRUE, &aCell)) {
  74.         *choice = aCell.v;
  75.         return (TRUE);
  76.     } else {
  77.         *choice = -1;
  78.         return (FALSE);
  79.     }
  80.  
  81. } /* GetChoice */
  82.  
  83. /******************************************************************************
  84.  SetChoice
  85.  
  86.     This is a wrapper routine for the very common kind of list which
  87.     has a single column and allows only one item to be selected.
  88.     Selects the cell in the specified row.
  89. ******************************************************************************/
  90. void    CAMTable::SetChoice        (short            choice)
  91. {
  92.     Cell            aCell;
  93.  
  94.     SetPt (&aCell, 0, choice);
  95.     SelectCell (aCell, FALSE /*keepPrevious*/, TRUE /*reDraw*/);
  96.  
  97. } /* SetChoice */
  98.